package com.hackerrank.challenges.insertionsortpart1;

// Head ends here
import java.util.*;
public class Solution {

	static void insertionSort(int[] ar) {
		int i = ar.length - 1, V = ar[i];
		for(; i > 0 && ar[i - 1] > V; i--) {
			ar[i] = ar[i - 1];
			printArray(ar);
		}
		ar[i] = V;
		printArray(ar);
	}   

	// Tail starts here
	static void printArray(int[] ar) {
		for(int n: ar)
			System.out.print(n + " ");
		System.out.println("");
	}

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] ar = new int[n];
		for(int i=0;i<n;i++)
			ar[i]=in.nextInt(); 
		insertionSort(ar);
	}    
}
